package network.course3;

public class SubtractorTest implements Runnable{
   private  int count;

    public SubtractorTest(int count) {
        this.count = count;
    }
    int i=0;
    @Override
    public synchronized void run() {
        try {
        while (i<=count){
            System.out.println(i);
            i++;
        }

            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        SubtractorTest subtractorTest=new SubtractorTest(15);
        SubtractorTest subtractorTest1=new SubtractorTest(10);
        Thread thread1=new Thread(subtractorTest);
        Thread thread2=new Thread(subtractorTest1);
        thread1.start();
        thread1.join();
        thread2.start();
        thread2.join();
    }
}
